package app.server.project.main.service.controller;

import app.server.project.core.constants.Def;
import app.server.project.core.http.RespModel;
import app.server.project.main.service.dto.sign.SignResp;
import app.server.project.main.service.service.LoginEnergyService;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 7天登录免费领取体力模块
 */
@AllArgsConstructor
@RestController
@RequestMapping("/loginFreeEnergy")
public class LoginFreeEnergyController {

    private LoginEnergyService loginEnergyService;


    /**
     * 领取免费体力
     *
     * @param userId
     */
    @PostMapping("/drawEnergy")
    public RespModel drawEnergy(@RequestHeader(Def.UserId) long userId) {
        this.loginEnergyService.drawEnergy(userId);
        return RespModel.success();
    }


    /**
     * 获取可以免费领取体力值
     */
    @PostMapping("/getFreeNum")
    public RespModel<Long> getFreeNum(@RequestHeader(Def.UserId) long userId) {
        return RespModel.success(this.loginEnergyService.getFreeNum(userId));
    }

    /**
     * 拉取最近30天签到列表
     */
    @PostMapping("/getSigns")
    public RespModel<SignResp> getSigns(@RequestHeader(Def.UserId) long userId) {
        return RespModel.success(this.loginEnergyService.getSigns(userId));
    }
}
